﻿#include "certcontent.h"
#include "ui_certcontent.h"

CertContent::CertContent(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CertContent)
{
    ui->setupUi(this);

    m_userImageIndex = 0;
    initWindowShow();
}

CertContent::~CertContent()
{
    delete ui;
}

void CertContent::initWindowShow()
{
    UserInfo user(GlobalVars::g_userInfoList->at(GlobalVars::g_userInfoList->size()-1));

    m_userID = user.getNumber();
    ui->lb_name->setText(user.getName());
    ui->lb_sex->setText(user.getSex());
    ui->lb_realName->setText(user.getRealName());
    qDebug() << "m_userID = " << m_userID;
}
const QString& CertContent::getUserID()
{
    return m_userID;
}
void CertContent::setUserImage(const QImage& image)
{
    switch (m_userImageIndex)
    {
        case 0:
        {
            QPixmap pixMap = QPixmap::fromImage(image.scaled(100,100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
            pixMap =  GlobalVars::PixmapToRound(pixMap, 50); ///50为圆形的半径
            ui->lb_headPic->setPixmap(pixMap);
        }  break;
        case 1: ui->lb_certImage0->setPixmap(QPixmap::fromImage(image.scaled(120,120))); break;
        case 2: ui->lb_certImage1->setPixmap(QPixmap::fromImage(image.scaled(120,120))); break;
        default: break;
    }

    m_userImageIndex++;
}

void CertContent::on_pb_pass_clicked()
{
    emit signalPassCert(true,m_userID);
}

void CertContent::on_pb_noPass_clicked()
{
    emit signalPassCert(false,m_userID);
}
